package com.watson.todolist;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * This class handles the variois user options under the settings menu item
 * 
 * @author Lauren Tanguay
 * 
 * @since 1.0
 * 
 */
public class SettingsPageActivity extends Activity {

	private static String TAG = "SettingsPageActivity Class";

	/**
	 * This method is called when the activity is created.
	 * 
	 * @param savedInstanceState
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.settingslayout);

		Log.d(TAG, "Settings page opened");

		Button menuButtonMain = (Button) findViewById(R.id.menuButtonMain);
		Button menuButtonAdd = (Button) findViewById(R.id.menuButtonAdd);
		Button menuButtonSearch = (Button) findViewById(R.id.menuButtonSearch);
		Button menuButtonSettings = (Button) findViewById(R.id.menuButtonSettings);
		
		Button logout = (Button) findViewById(R.id.logout);

		// change background image of settings menu button (current screen)
		menuButtonSettings.setBackgroundResource(R.drawable.menu_settings_);

		// Set up main menu button listener
		menuButtonMain.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(),
						todoListActivity.class);
				startActivity(intent);
			}
		});

		// Set up search todo button listener
		menuButtonSearch.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), SearchTodoList.class);
				startActivity(intent);
			}
		});

		// Set up create todo item button listener
		menuButtonAdd.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), AddTodoItem.class);
				startActivity(intent);
			}
		});
		
		// Set up logout button listener
				logout.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						Intent intent = new Intent(Intent.ACTION_MAIN);
						intent.addCategory(Intent.CATEGORY_HOME);
						intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
						startActivity(intent);
					}
				});
	}

}
